#include<stdio.h>
int main() {
    int m,i,c;
    scanf("%d",&m);
    int arr[100000];
    for (i = 0; i < m; i++) {
        scanf("%d",&c);
        arr[i] = c;
    }
    int hang,sum;
    scanf("%d",&hang);
    for (i = 0; i < hang; i++) {
        int start, end;
        scanf("%d",&start);
        scanf("%d",&end);
        sum = 0;
        for (int j = start -1; j <= end -1;j++)
            sum += arr[j];
        printf("%d\n", sum);
    }
}
